home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre3.z / postgre3 / src / lib / H / tcop / slaves.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  4.7 KB  |  144 lines

  1. /* ----------------------------------------------------------------
  2.  *   FILE
  3.  *    slaves.h
  4.  *    
  5.  *   DESCRIPTION
  6.  *    macros and definitions for parallel backends
  7.  *
  8.  *   NOTES
  9.  *
  10.  *   IDENTIFICATION
  11.  *    $Header: /private/postgres/src/lib/H/tcop/RCS/slaves.h,v 1.10 1992/01/21 16:40:47 hong Exp $
  12.  * ----------------------------------------------------------------
  13.  */
  14.  
  15. #ifndef SlavesIncluded
  16. #define SlavesIncluded
  17. #include "utils/rel.h"
  18. #include "nodes/plannodes.h"
  19. #include "executor/execshmem.h"
  20.  
  21. extern int MyPid;
  22. #define IsMaster    (MyPid == -1)
  23.  
  24. extern int ParallelExecutorEnableState;
  25. #define ParallelExecutorEnabled()    ParallelExecutorEnableState
  26. extern int NumberSlaveBackends;
  27. #define GetNumberSlaveBackends()    NumberSlaveBackends
  28.  
  29. /* slave info will stay in shared memory */
  30. struct slaveinfo {
  31.     int        unixPid;        /* the unix process id -- for sending
  32.                        signals */
  33.     int        groupId;        /* Id of the process group this slave
  34.                        belongs to */
  35.     int        groupPid;        /* virtual pid within the process 
  36.                        group */
  37.     bool    isAddOnSlave;        /* true if is add-on slave */
  38.     bool    isDone;            /* true if slave has finished task and
  39.                        is waiting for others to finish */
  40.     Relation    resultTmpRelDesc;    /* the reldesc of the tmp relation
  41.                        that holds the result of this
  42.                        slave backend */
  43.     int        curpage;        /* current page being scanned:
  44.                        for communication with master */
  45. #ifdef HAS_TEST_AND_SET
  46.     slock_t    lock;            /* mutex lock for comm. with master */
  47. #endif
  48. };
  49. typedef struct slaveinfo SlaveInfoData;
  50. typedef SlaveInfoData *SlaveInfo;
  51. extern SlaveInfo SlaveInfoP;
  52.  
  53. struct slavelocalinfo {
  54.     int            nparallel;    /* degree of parallelism */
  55.     int            startpage;    /* heap scan starting page number */
  56.     bool        paradjpending;    /* parallelism adjustment pending */
  57.     int            paradjpage;   /* page on which to adjust parallelism */
  58.     int            newparallel;  /* new page skip */
  59.     bool        isworking; /* true if the slave is working */
  60.     HeapScanDesc    heapscandesc; /* heap scan descriptor */
  61.     IndexScanDesc    indexscandesc; /* index scan descriptor */
  62. };
  63. typedef struct slavelocalinfo SlaveLocalInfoData;
  64. extern SlaveLocalInfoData SlaveLocalInfoD;
  65.  
  66. typedef enum { IDLE, FINISHED, WORKING, PARADJPENDING }        ProcGroupStatus;
  67. /* pgroupinfo will stay in shared memory */
  68. struct pgroupinfo {
  69.     ProcGroupStatus status;    /* status of the process group */
  70.     List    queryDesc;    /* querydesc for the process group */
  71.     int        countdown;    /* countdown of # of proc in progress */
  72.     int        nprocess;    /* # of processes in group */
  73.     SharedCounter scounter;    /* a shared counter for sync purpose */
  74.     SharedCounter dropoutcounter; /* a counter for drop out slaves */
  75.     M1Lock    m1lock; /* one producer multiple consumer lock for comm. */
  76.     int         paradjpage;   /* page on which to adjust parallelism */
  77.     int         newparallel;  /* new page skip */
  78. };
  79. typedef struct pgroupinfo ProcGroupInfoData;
  80. typedef ProcGroupInfoData *ProcGroupInfo;
  81. extern ProcGroupInfo ProcGroupInfoP;
  82.  
  83. /* the following structs will be kept in master's memory only */
  84. struct procnode {
  85.     int            pid;
  86.     struct procnode    *next;
  87. };
  88. typedef struct procnode ProcessNode;
  89. extern int NumberOfFreeSlaves;
  90.  
  91. struct lpgroupinfo {
  92.     int            id;
  93.     Fragment        fragment;
  94.     ProcessNode        *memberProc;
  95.     MemoryHeader    groupSMQueue;
  96.     struct lpgroupinfo    *nextfree;
  97.     List        resultTmpRelDescList;
  98. };
  99. typedef struct lpgroupinfo ProcGroupLocalInfoData;
  100. typedef ProcGroupLocalInfoData *ProcGroupLocalInfo;
  101. extern ProcGroupLocalInfo ProcGroupLocalInfoP;
  102.  
  103. struct schedulinginfo {
  104.     int        ioBoundGroupId;
  105.     Fragment    ioBoundFrag;
  106.     int        cpuBoundGroupId;
  107.     Fragment    cpuBoundFrag;
  108. };
  109. typedef struct schedulinginfo MasterSchedulingInfoData;
  110.  
  111. /* slaves.c */
  112. void SendAbortSignals ARGS((void ));
  113. void SlaveRestart ARGS((void ));
  114. void SlaveBackendsAbort ARGS((void ));
  115. void SlaveMain ARGS((void ));
  116. void MoveTransactionState ARGS((void ));
  117. void SlaveBackendsInit ARGS((void ));
  118. int getFreeSlave ARGS((void ));
  119. void freeSlave ARGS((int i ));
  120. int getFreeProcGroup ARGS((int nproc ));
  121. void addSlaveToProcGroup ARGS((int slave , int group , int groupid ));
  122. void freeProcGroup ARGS((int gid ));
  123. int getFinishedProcGroup ARGS((void ));
  124. void wakeupProcGroup ARGS((int groupid ));
  125. void signalProcGroup ARGS((int groupid , int sig ));
  126. void ProcGroupSMBeginAlloc ARGS((int groupid ));
  127. void ProcGroupSMEndAlloc ARGS((void ));
  128. char *ProcGroupSMAlloc ARGS((int size ));
  129. void ProcGroupSMClean ARGS((int groupid ));
  130. void SlaveTmpRelDescInit ARGS((void ));
  131. char *SlaveTmpRelDescAlloc ARGS((int size ));
  132. int getProcGroupMaxPage ARGS((int groupid ));
  133. int paradj_handler ARGS((void ));
  134. int paradj_nextpage ARGS((int page , int dir ));
  135.  
  136. #define SIGPARADJ    SIGUSR1
  137.  
  138. #define NULLPAGE    -1
  139. #define NOPARADJ    -2
  140.  
  141. typedef enum {INTRA_ONLY, INTER_W_ADJ, INTER_WO_ADJ}    ParallelismModes;
  142.  
  143. #endif  TcopIncluded
  144.